package view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.xuegengwang.xuegengwang.R;
import com.makeramen.roundedimageview.RoundedImageView;

/**
 * Created by Administrator on 2017/5/5.
 */

public class EncashDialog extends Dialog {
    private RoundedImageView roundedImageView;
    private TextView count;
    private Button reBind;
    private Button confirm;
    private ReBindListener reBindListener;
    private ConfirmListener confirmListener;

    public EncashDialog(Context context) {
        super(context, R.style.confirmDialog);
    }

    public EncashDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    protected EncashDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.encash_dialog);
        roundedImageView = (RoundedImageView) findViewById(R.id.encash_dialog_img);
        count = (TextView) findViewById(R.id.encash_dialog_count);
        reBind = (Button) findViewById(R.id.encash_dialog_reBind);
        confirm = (Button) findViewById(R.id.encash_dialog_confirm);
        reBind.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EncashDialog.this.dismiss();
                if(reBindListener!=null) {
                    reBindListener.reBindListener();
                }
            }
        });

        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EncashDialog.this.dismiss();
                if(confirmListener!=null) {
                    confirmListener.confirmListener();
                }
            }
        });
    }

    public void setInformation(String count,String imaUrl){
        this.count.setText(count);
        MyImageLoader.showImage(imaUrl,roundedImageView);
    }

    public void setReBindListener(ReBindListener reBindListener) {
        this.reBindListener = reBindListener;
    }

    public void setConfirmListener(ConfirmListener confirmListener) {
        this.confirmListener = confirmListener;
    }

    public interface ReBindListener{
        void reBindListener();
    }

    public interface ConfirmListener{
        void confirmListener();
    }
}
